package org.apache.hadoop.hdfs.server.datanode;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;

public class LatchedArrayBlockingQueue<T> extends ArrayBlockingQueue<T> {

	private static final long serialVersionUID = 1L;
	
	private boolean stopTakingData = false;
	
	public LatchedArrayBlockingQueue(int capacity) {
		super(capacity);
	}

	public boolean isStopReceivingData() {
		return stopTakingData;
	}

	public void setStopTakingData(boolean stopTakingData) {
		this.stopTakingData = stopTakingData;
		if (stopTakingData) {
			super.clear();
		}
		
	}
	
	@Override
	public void put(T t) throws InterruptedException {
		if (!stopTakingData) {
			super.put(t);
		}
	}

	
}